package com.reger.l2cache.pipeline.core;

public interface PipelineCore {

	static final Callback<?> DEFAULT_CALLBACK = obj -> obj;

	/**
	 * 执行redis命名
	 * 
	 * @param operations 具体的命名操作
	 * @param callback   操作回调
	 * @param relust     是否需要返回数据处理
	 * @return
	 */
	<T> T execute(Operations operations, Callback<T> callback, boolean relust);

	/**
	 * 执行有返回值的redis操作
	 * 
	 * @param operations
	 * @param callback
	 * @return
	 */
	default <T> T execute(Operations operations, Callback<T> callback) {
		return execute(operations, callback, true);
	}

	/**
	 * 执行有返回值的redis操作
	 * 
	 * @param operations
	 * @return
	 */
	@SuppressWarnings("unchecked")
	default <T> T execute(Operations operations) {
		return execute(operations, (Callback<T>) DEFAULT_CALLBACK);
	};

	/**
	 * 执行没有返回值的redis操作
	 * 
	 * @param operations
	 * @return
	 */
	@SuppressWarnings("unchecked")
	default <T> T executeNoRelust(Operations operations) {
		return execute(operations, (Callback<T>) DEFAULT_CALLBACK, false);
	};
}
